package com.tank.demo.utils;

import lombok.Data;
import lombok.ToString;

import java.io.IOException;
import java.util.Properties;

//@Data
//@ToString
/**
 * 静态内部类方法实现单例模式
 */
public class PropertyMgr {
    private Properties properties = new Properties();

    private PropertyMgr(){
        try {
            properties.load(PropertyMgr.class.getClassLoader().getResourceAsStream("application.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    private static class PropertyMgrHolder{
        private static PropertyMgr INSTANCE = new PropertyMgr();
    }
    public static PropertyMgr getInstance(){
        return PropertyMgrHolder.INSTANCE;
    }
    public String getKey(String key){
        return properties.getProperty(key);
    }
}
